package edu.cuit.avatar.common.converter;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;

/**
 * @author <a href="mailto:1020zhaodan@163.com">Adan</a>
 * @version 1.0
 * @date 2025/7/26 10:33
 */
public class ConverterRegister {
    private static final Map<Class<?>, Converter> converters = new HashMap<>();

    static {
        converters.put(LocalDate.class, new LocalDateConverter());
        converters.put(LocalDateTime.class, new LocalDateTimeConverter());
        converters.put(int.class, new IntegerConverter());
        converters.put(Integer.class, new IntegerConverter());
    }

    public static<S,T> void register(Class<T> clazz,Converter<S, T> converter){
        converters.put(clazz,converter);
    }

    public static<T> Converter getConverter(Class<T> clazz){
        return converters.get(clazz);
    }
}
